<script setup lang="ts">
import { ref } from 'vue'
import { Calendar, User } from '@element-plus/icons-vue'

interface MedicalRecord {
  id: number
  patientName: string
  date: string
  type: string
  medications: string[]
  description: string
}

const medicalRecords = ref<MedicalRecord[]>([
  {
    id: 1,
    patientName: '张明',
    date: '2024-03-15',
    type: '季节性感冒',
    medications: ['布洛芬', '维生素C'],
    description: '感冒症状，建议多休息'
  },
  {
    id: 2,
    patientName: '李芳',
    date: '2024-03-14',
    type: '关节炎复查',
    medications: ['布洛芬缓释胶囊', '葡萄糖胺'],
    description: '关节炎情况稳定'
  },
  {
    id: 3,
    patientName: '王建国',
    date: '2024-03-13',
    type: '高血压随访',
    medications: ['降压药', '降脂药'],
    description: '血压控制良好'
  }
])
</script>

<template>
  <div class="medical-care">
    <div class="page-header">
      <div class="header-content">
        <h1>医疗护理</h1>
        <p class="subtitle">专业的医疗保健服务</p>
      </div>
      <el-button type="primary" class="add-button">
        <el-icon><Plus /></el-icon>
        添加记录
      </el-button>
    </div>

    <el-row :gutter="24">
      <el-col :span="8" v-for="record in medicalRecords" :key="record.id">
        <el-card class="medical-card" shadow="hover">
          <div class="medical-header">
            <div class="patient-info">
              <el-icon><User /></el-icon>
              <h3>{{ record.patientName }}</h3>
            </div>
            <div class="date-info">
              <el-icon><Calendar /></el-icon>
              <span>{{ record.date }}</span>
            </div>
          </div>

          <div class="medical-content">
            <div class="diagnosis">
              <h4>诊断类型</h4>
              <el-tag effect="plain" class="type-tag">{{ record.type }}</el-tag>
            </div>

            <div class="medications">
              <h4>用药记录</h4>
              <div class="medication-list">
                <el-tag 
                  v-for="medication in record.medications" 
                  :key="medication"
                  class="medication-tag"
                  type="info"
                  effect="plain"
                >
                  {{ medication }}
                </el-tag>
              </div>
            </div>

            <div class="description">
              <h4>医嘱说明</h4>
              <p>{{ record.description }}</p>
            </div>
          </div>

          <div class="medical-actions">
            <el-button text>编辑记录</el-button>
            <el-button type="primary" plain>查看详情</el-button>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<style scoped lang="scss">
.medical-care {
  .page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;

    .header-content {
      h1 {
        font-size: 28px;
        font-weight: 600;
        margin: 0 0 8px;
        color: var(--primary-text);
      }

      .subtitle {
        font-size: 16px;
        color: var(--secondary-text);
        margin: 0;
      }
    }

    .add-button {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 12px 24px;
      font-size: 16px;
    }
  }

  .medical-card {
    margin-bottom: 24px;

    .medical-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 24px;

      .patient-info {
        display: flex;
        align-items: center;
        gap: 12px;

        h3 {
          font-size: 20px;
          font-weight: 600;
          margin: 0;
          color: var(--primary-text);
        }
      }

      .date-info {
        display: flex;
        align-items: center;
        gap: 8px;
        color: var(--secondary-text);
      }
    }

    .medical-content {
      .diagnosis, .medications, .description {
        margin-bottom: 20px;

        h4 {
          font-size: 16px;
          font-weight: 600;
          margin: 0 0 12px;
          color: var(--primary-text);
        }
      }

      .type-tag {
        font-size: 14px;
        padding: 6px 12px;
        border-radius: 16px;
      }

      .medication-list {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;

        .medication-tag {
          border-radius: 16px;
          padding: 6px 12px;
          font-size: 14px;
        }
      }

      .description {
        p {
          margin: 0;
          color: var(--secondary-text);
          font-size: 14px;
          line-height: 1.6;
        }
      }
    }

    .medical-actions {
      display: flex;
      justify-content: flex-end;
      gap: 12px;
      margin-top: 24px;
      padding-top: 24px;
      border-top: 1px solid var(--secondary-bg);
    }
  }
}
</style>